let app = getApp()
import {imageUrl} from "../utils/imageutil"
import {Intranetnet_bx} from "../utils/api"
Page({
  data: {
    imageUrl,
    order_id:'',
    flag:true,
    page:1,
    housekeeperList:[],
    aunt_info:{},
    do:'',
    do_data:null,
    type:0,

  },
 
  onLoad(options) {
    console.log(options);
    wx.removeStorageSync('get_aunt_info');
    
    this.setData({
      order_id:options.order_id,
      type:options.type
    })

    if(options.is_shop=='true'){
      this.setData({
        do:'xieBaoCtr/queryStoreKeep',
        do_data:{
          userId:wx.getStorageSync('merchant').admin.storeid,
        }
      })
    }else{
      this.setData({
        do:'xieBaoCtr/queryWorkHouse',
        do_data:{
          uid:this.data.order_id,
        }
      })
    }
    this.gethousekeeperList()
  },

  onReachBottom(){
    this.gethousekeeperList()
  },

  gethousekeeperList(){
    if(!this.data.flag){
      return
    }
    wx.request({
      url: Intranetnet_bx+this.data.do,
      method:"POST",
      header: {
        "Content-Type": "application/x-www-form-urlencoded"
      },
      data:{
        ...this.data.do_data,
      },
      success:((res)=>{
        this.setData({
          housekeeperList:res.data.data
        })
      })

    })
  },

  changekeywords(e){//搜索家政员
    this.setData({
      name:e.detail.value,
      page:1,
      flag:true,
      housekeeperList:[],
    })
    this.gethousekeeperList()
  },

  change_aunt(e){
    this.setData({
      aunt_info:this.data.housekeeperList[e.detail.value]
    })
  },

  bottomTap(){
    console.log(this.data.type);
    console.log(this.data.aunt_info);
    let aa = {...this.data.aunt_info,...{type:this.data.type ? this.data.type : 0}};
    // return
    console.log(aa);
    wx.setStorageSync('get_aunt_info', aa)
    wx.navigateBack({
      delta: 1,
    })
  },
 
})